package com.ruoyi.safe.service.impl;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.safe.common.ItemValue;
import com.ruoyi.safe.constant.CatalogConstants;
import com.ruoyi.safe.domain.BizCatalogDetail;
import com.ruoyi.safe.domain.BizSafeDocAttach;
import com.ruoyi.safe.domain.BizSafeInfor;
import com.ruoyi.safe.domain.dto.BizSafeInfoCoverAttachDTO;
import com.ruoyi.safe.domain.dto.BizSafeInforAppendAttachDTO;
import com.ruoyi.safe.domain.dto.BizSafeInforFileListDTO;
import com.ruoyi.safe.domain.dto.BizSafeInforRelateCatalogDTO;
import com.ruoyi.safe.domain.vo.BizSafeDocAttachVO;
import com.ruoyi.safe.domain.vo.SafeInforStatisticVo;
import com.ruoyi.safe.mapper.BizCatalogDetailMapper;
import com.ruoyi.safe.mapper.BizSafeDocAttachMapper;
import com.ruoyi.safe.mapper.BizSafeInforMapper;
import com.ruoyi.safe.service.IBizSafeDocAttachService;
import com.ruoyi.safe.service.IBizSafeInforService;
import com.ruoyi.system.mapper.SysDeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 安全内业资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-10
 */
@Service
public class BizSafeInforServiceImpl implements IBizSafeInforService
{
    @Autowired
    BizSafeInforMapper bizSafeInforMapper;
    @Autowired
    BizCatalogDetailMapper bizCatalogDetailMapper;
    @Autowired
    BizSafeDocAttachMapper bizSafeDocAttachMapper;
    @Autowired
    IBizSafeDocAttachService bizSafeDocAttachService;
    @Autowired
    SysDeptMapper sysDeptMapper;

    /**
     * 查询安全内业资料
     *
     * @param id 安全内业资料主键
     * @return 安全内业资料
     */
    @Override
    public BizSafeInfor selectBizSafeInforById(Long id)
    {
        BizSafeInfor bizSafeInfor = bizSafeInforMapper.selectBizSafeInforById(id);
        BizSafeDocAttach bizSafeDocAttach = new BizSafeDocAttach();
        bizSafeDocAttach.setCatalogDetailId(id);
        List<BizSafeDocAttachVO> bizSafeDocAttaches = bizSafeDocAttachService.selectBizSafeDocAttachList(bizSafeDocAttach);
        bizSafeInfor.setBizSafeDocAttachList(bizSafeDocAttaches);
        return bizSafeInfor;
    }

    /**
     * 查询安全内业资料列表
     *
     * @param bizSafeInfor 安全内业资料
     * @return 安全内业资料
     */
    @Override
    public List<BizSafeInfor> selectBizSafeInforList(BizSafeInfor bizSafeInfor)
    {
        return bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
    }

    /**
     * 新增安全内业资料(只能是一级目录)
     *
     * @param bizSafeInfor 安全内业资料
     * @return 结果
     */
    @Override
    public int insertBizSafeInfor(BizSafeInfor bizSafeInfor)
    {
        bizSafeInfor.setParentId(CatalogConstants.ROOT_ID);
        bizSafeInfor.setAncestors(CatalogConstants.ROOT_ID_CHAR);
        bizSafeInfor.setCreateJunior(CatalogConstants.NEED_CREATE_JUNIOR);
        bizSafeInfor.setCatalogId(null);
        bizSafeInfor.setUpdateBy(null);
        bizSafeInfor.setUpdateTime(null);
        bizSafeInfor.setDeptId(SecurityUtils.getDeptId());
        bizSafeInfor.setCreateTime(DateUtils.getNowDate());
        bizSafeInfor.setCreateBy(SecurityUtils.getUsername());
        return bizSafeInforMapper.insertBizSafeInfor(bizSafeInfor);
    }

    /**
     * 修改安全内业资料
     *
     * @param bizSafeInfor 安全内业资料
     * @return 结果
     */
    @Override
    public int updateBizSafeInfor(BizSafeInfor bizSafeInfor)
    {
        if(CatalogConstants.NO_NEED_CREATE_JUNIOR.equals(bizSafeInfor.getCreateJunior())){
            //如果设置为不需要创建下级，则需要判断这个节点下面是否有下级节点
            List<BizSafeInfor> bizSafeInfors =  bizSafeInforMapper.selectBizSafeInforByParentId(bizSafeInfor.getId());
            if(bizSafeInfors.size()>0){
                throw new ServiceException("当前目录存在子级，不能改变'是否创建下级'状态");
            }
        }else if(CatalogConstants.NEED_CREATE_JUNIOR.equals(bizSafeInfor.getCreateJunior())){
            //设置为需要创建下级，则需要判断目录中没有模板文件
            List<BizSafeDocAttach> bizSafeDocAttaches = bizSafeDocAttachMapper.selectListByDetailId(bizSafeInfor.getId());
            if(bizSafeDocAttaches.size() > 0){
                //不能设置为需要创建下级
                throw new ServiceException("当前目录存在文件，不能改变'是否创建下级'状态");
            }
        }
        BizSafeInfor parentBizSafeInfo = bizSafeInforMapper.selectBizSafeInforById(bizSafeInfor.getParentId());
        String ancestors = String.valueOf(parentBizSafeInfo.getParentId());
        if(parentBizSafeInfo != null){
            ancestors = parentBizSafeInfo.getPath();
        }
        bizSafeInfor.setAncestors(ancestors);
        bizSafeInfor.setUpdateTime(DateUtils.getNowDate());
        bizSafeInfor.setUpdateBy(SecurityUtils.getUsername());
        return bizSafeInforMapper.updateBizSafeInfor(bizSafeInfor);
    }

    /**
     * 批量删除安全内业资料
     *
     * @param ids 需要删除的安全内业资料主键
     * @return 结果
     */
    @Override
    public int deleteBizSafeInforByIds(Long[] ids)
    {
        return bizSafeInforMapper.deleteBizSafeInforByIds(ids);
    }

    /**
     * 删除安全内业资料信息
     *
     * @param id 安全内业资料主键
     * @return 结果
     */
    @Override
    public int deleteBizSafeInforById(Long id)
    {
        return bizSafeInforMapper.deleteBizSafeInforById(id);
    }

    @Override
    public List<BizSafeInfor> selectListByProjectId(Long projectId) {
        BizSafeInfor bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        List<BizSafeInfor> bizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
        if(bizSafeInfors.size() > 0){
            Long[] deptIds = bizSafeInfors.stream().map(item->item.getDeptId()).distinct().collect(Collectors.toList()).toArray(new Long[0]);
            List<SysDept> sysDepts = sysDeptMapper.selectListByIds(deptIds);
            Map<Long,String> sysDeptMap = sysDepts.stream().collect(Collectors.toMap(SysDept::getDeptId,SysDept::getDeptName));
            bizSafeInfors.stream().forEach(item -> {
                item.setDeptName(sysDeptMap.get(item.getDeptId()));
            });
        }
        return bizSafeInfors;
    }

    @Override
    public int createJunior(Long parentId, BizSafeInfor bizSafeInfor) {
        bizSafeInfor.setParentId(parentId);
        if(CatalogConstants.ROOT_ID.equals(parentId)){
            if(bizSafeInfor.getProjectId() == null){
                throw new ServiceException("新建一级目录必须传入projectId");
            }else{
                //祖先路径
                bizSafeInfor.setAncestors(CatalogConstants.ROOT_ID_CHAR);
            }
        }else{
            //父ID
            BizSafeInfor parentBizSafeInfo = bizSafeInforMapper.selectBizSafeInforById(parentId);
            //校验是否能够去创建下级
            if(CatalogConstants.NO_NEED_CREATE_JUNIOR.equals(parentBizSafeInfo.getCreateJunior())){
                //如果父节点不需要要创建下级，则直接返回
                throw new ServiceException(("当前目录不能创建下级"));
            }
            //目录id
            bizSafeInfor.setCatalogId(parentBizSafeInfo.getCatalogId());
            //所属的项目
            bizSafeInfor.setProjectId(parentBizSafeInfo.getProjectId());
            //祖先路径
            bizSafeInfor.setAncestors(parentBizSafeInfo.getPath());
        }
        //部门ID
        bizSafeInfor.setDeptId(SecurityUtils.getDeptId());
        bizSafeInfor.setCreateTime(DateUtils.getNowDate());
        bizSafeInfor.setCreateBy(SecurityUtils.getUsername());
        bizSafeInfor.setUpdateTime(DateUtils.getNowDate());
        return bizSafeInforMapper.insertBizSafeInfor(bizSafeInfor);
    }

    @Override
    public int relateCatalog(BizSafeInforRelateCatalogDTO bizSafeInforRelateCatalogDTO) {
        Long catalogId = bizSafeInforRelateCatalogDTO.getCatalogId();
        Long projectId = bizSafeInforRelateCatalogDTO.getProjectId();
        //校验是否引用了当前的目录
        BizSafeInfor bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        bizSafeInfor.setCatalogId(catalogId);
        List<BizSafeInfor> bizSafeInforList = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
        if(bizSafeInforList.size() > 0){
            throw new ServiceException("当前项目已经引用过该目录,不能重复引用");
        }
        //从跟目录开始迁移
        BizCatalogDetail bizCatalogDetail = new BizCatalogDetail();
        bizCatalogDetail.setCatalogId(catalogId);
        bizCatalogDetail.setParentId(0l);
        List<BizCatalogDetail> bizCatalogDetails = bizCatalogDetailMapper.selectBizCatalogDetailList(bizCatalogDetail);
        copyBizCatalogDetails(bizCatalogDetails,projectId);
        return 1;
    }

    @Override
    public List<SafeInforStatisticVo> firstLevelSafeInforStatistics(Long projectId) {
        List<SafeInforStatisticVo> safeInforStatisticVos = new ArrayList<>();
        //统计的是需要上传的目录中已上传资料的目录
        //查询需要上传的目录数量
        BizSafeInfor bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        bizSafeInfor.setCreateJunior(CatalogConstants.NO_NEED_CREATE_JUNIOR);
        //需要上传文件的目录集合
        List<BizSafeInfor> needUploadFileBizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
        if(needUploadFileBizSafeInfors.size() > 0){
            //生成需要上传文件的目录的id集合
            List<Long> needUploadFileBizSafeInforIds = needUploadFileBizSafeInfors.stream().map(item->item.getId()).collect(Collectors.toList());
            List<ItemValue> keyValues = bizSafeDocAttachMapper.groupBizSafeDocAttachByDetailIds(needUploadFileBizSafeInforIds);
            //生成已经上传文件的目录的id集合
            List<Long> uploadedFileSafeInforIds = keyValues.stream().map(item->Long.valueOf(item.getItem())).collect(Collectors.toList());

            //查询第一级的目录列表
            bizSafeInfor = new BizSafeInfor();
            bizSafeInfor.setProjectId(projectId);
            bizSafeInfor.setParentId(CatalogConstants.ROOT_ID);
            List<BizSafeInfor> firstLevelSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
            List<BizSafeInfor> uploadedFileSafeInfors = new ArrayList<>();
            if(uploadedFileSafeInforIds.size() > 0) {
                //生成已上传文件的目录集合
                uploadedFileSafeInfors = bizSafeInforMapper.selectBizSafeInforListByIds(uploadedFileSafeInforIds);
            }
            //遍历一级目录
            for (int i = 0; i < firstLevelSafeInfors.size(); i++) {
                BizSafeInfor item = firstLevelSafeInfors.get(i);
                String path = item.getPath();
                Long needUploadCount = needUploadFileBizSafeInfors.stream().filter(needUploadFileBizSafeInfor->{
                    if(needUploadFileBizSafeInfor.getId().equals(item.getId()) || needUploadFileBizSafeInfor.getPath().startsWith(path + ",")){
                        return true;
                    }
                    return false;
                }).count();

                Long uploadedCount = uploadedFileSafeInfors.stream().filter(needUploadFileBizSafeInfor->{
                    if(needUploadFileBizSafeInfor.getId().equals(item.getId()) || needUploadFileBizSafeInfor.getPath().startsWith(path + ",")){
                        return true;
                    }
                    return false;
                }).count();
                SafeInforStatisticVo safeInforStatisticVo = SafeInforStatisticVo.builder().safeInforId(item.getId()).safeInforName(item.getName()).needUploadCount(needUploadCount).uploadedCount(uploadedCount).build();
                safeInforStatisticVos.add(safeInforStatisticVo);
            }
        }
        return safeInforStatisticVos;
    }

    @Override
    public SafeInforStatisticVo safeInforStatistics(Long projectId) {
        SafeInforStatisticVo safeInforStatisticVo = SafeInforStatisticVo.builder().build();
        //查询需要上传的目录数量
        BizSafeInfor bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        bizSafeInfor.setCreateJunior(CatalogConstants.NO_NEED_CREATE_JUNIOR);
        //需要上传文件的目录集合
        List<BizSafeInfor> needUploadFileBizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
        //生成需要上传文件的目录的id集合
        List<Long> needUploadFileBizSafeInforIds = needUploadFileBizSafeInfors.stream().map(item->item.getId()).collect(Collectors.toList());
        if(needUploadFileBizSafeInforIds.size() > 0){
            List<ItemValue> keyValues = bizSafeDocAttachMapper.groupBizSafeDocAttachByDetailIds(needUploadFileBizSafeInforIds);
            //生成已经上传文件的目录的id集合
            List<Long> uploadedFileSafeInforIds = keyValues.stream().map(item->Long.valueOf(item.getItem())).collect(Collectors.toList());
            safeInforStatisticVo = SafeInforStatisticVo.builder().needUploadCount((long)needUploadFileBizSafeInforIds.size()).uploadedCount((long)uploadedFileSafeInforIds.size()).build();
        }
        return safeInforStatisticVo;
    }

    @Override
    public List<BizSafeInfor> performance(Long projectId) {

        BizSafeInfor bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        //查询项目下所有的目录
        List<BizSafeInfor> allBizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);

        bizSafeInfor = new BizSafeInfor();
        bizSafeInfor.setProjectId(projectId);
        bizSafeInfor.setCreateJunior(CatalogConstants.NO_NEED_CREATE_JUNIOR);
        //需要上传文件的目录集合
        List<BizSafeInfor> needUploadFileBizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(bizSafeInfor);
        //生成需要上传文件的目录的id集合
        List<Long> needUploadFileBizSafeInforIds = needUploadFileBizSafeInfors.stream().map(item->item.getId()).collect(Collectors.toList());
        if(needUploadFileBizSafeInforIds.size() > 0){
            List<ItemValue> itemValues = bizSafeDocAttachMapper.groupBizSafeDocAttachByDetailIds(needUploadFileBizSafeInforIds);
            Map<String,Long> uploadedFileCountCache = itemValues.stream().collect(Collectors.toMap(ItemValue::getItem,ItemValue::getValue));
            //生成已经上传文件的目录的id集合
            List<Long> uploadedFileSafeInforIds = itemValues.stream().map(item->Long.valueOf(item.getItem())).collect(Collectors.toList());
            //生成已上传文件的目录集合
            List<BizSafeInfor> uploadedFileSafeInfors = new ArrayList<>();
            if(uploadedFileSafeInforIds.size() > 0){
                uploadedFileSafeInfors = bizSafeInforMapper.selectBizSafeInforListByIds(uploadedFileSafeInforIds);
            }

            //遍历目录
            for (int index = 0; index < allBizSafeInfors.size(); index++) {
                BizSafeInfor item = allBizSafeInfors.get(index);
                String path = item.getPath();
                long count = 0;
                List<BizSafeInfor> subBizSafeInfors = uploadedFileSafeInfors.stream().filter(needUploadFileBizSafeInfor->{
                    if(needUploadFileBizSafeInfor.getId().equals(item.getId()) || needUploadFileBizSafeInfor.getPath().startsWith(path + ",")){
                        return true;
                    }
                    return false;
                }).collect(Collectors.toList());
                for (int i = 0; i < subBizSafeInfors.size(); i++) {
                    count += uploadedFileCountCache.get(String.valueOf(subBizSafeInfors.get(i).getId()));
                }
                item.setUploadedFileCount(count);
            }
        }
        return allBizSafeInfors;
    }

    @Override
    public int relateAttaches(BizSafeInforAppendAttachDTO bizSafeInforAppendAttachDTO) {
        List<Long> attachIds = bizSafeInforAppendAttachDTO.getAttachIds();
        Long safeInforId = bizSafeInforAppendAttachDTO.getSafeInforId();
        //删除目录详情与附件的关联关系
        bizSafeDocAttachMapper.deleteBizSafeDocAttachRelationByDetailId(safeInforId);
        if(attachIds != null && attachIds.size() > 0){
            //当传入了内业资料文件或者模板文件时，需要检查当前目录是否能否创建下级
            BizSafeInfor bizSafeInfor = bizSafeInforMapper.selectBizSafeInforById(safeInforId);
            if(CatalogConstants.NEED_CREATE_JUNIOR.equals(bizSafeInfor.getCreateJunior())){
                //当前目录如果需要创建下级，则不能上传文件
                throw new ServiceException("当前目录需要创建下级，不能上传内业资料文件");
            }else{
                //重新设置关联关系
                return bizSafeDocAttachMapper.setDetailIdByIds(safeInforId,attachIds.toArray(new Long[0]));
            }
        }
        return 1;
    }

    @Override
    public int appendAttaches(BizSafeInforAppendAttachDTO bizSafeInforRelateAttachDTO) {
        List<Long> attachIds = bizSafeInforRelateAttachDTO.getAttachIds();
        Long safeInforId = bizSafeInforRelateAttachDTO.getSafeInforId();
        if(attachIds != null && attachIds.size() > 0){
            //当传入了内业资料文件或者模板文件时，需要检查当前目录是否能否创建下级
            BizSafeInfor bizSafeInfor = bizSafeInforMapper.selectBizSafeInforById(safeInforId);
            if(CatalogConstants.NEED_CREATE_JUNIOR.equals(bizSafeInfor.getCreateJunior())){
                //当前目录如果需要创建下级，则不能上传文件
                throw new ServiceException("当前目录需要创建下级，不能上传内业资料文件");
            }else{
                //重新设置关联关系
                return bizSafeDocAttachMapper.setDetailIdByIds(safeInforId,attachIds.toArray(new Long[0]));
            }
        }else{
            throw new ServiceException("附件不能为空");
        }
    }

    @Override
    public int coverAttache(BizSafeInfoCoverAttachDTO bizSafeInfoCoverAttachDTO) {
        BizSafeDocAttach oldBizSafeDocAttach = bizSafeDocAttachMapper.selectBizSafeDocAttachById(bizSafeInfoCoverAttachDTO.getOldAttachId());
        if(oldBizSafeDocAttach == null){
            throw new ServiceException("当前的安全内业资料文件不存在");
        }
        if(oldBizSafeDocAttach.getCatalogDetailId() == null){
            throw new ServiceException("当前文件没有关联安全内业资料");
        }
        //删除原有的目录详情与附件的关联关系
        Long[] ids = new Long[]{ bizSafeInfoCoverAttachDTO.getOldAttachId() };
        bizSafeDocAttachMapper.deleteBizSafeDocAttachRelationByIds(ids);
        //更新关联关系
        BizSafeDocAttach bizSafeDocAttach = new BizSafeDocAttach();
        bizSafeDocAttach.setId(bizSafeInfoCoverAttachDTO.getCurrentAttachId());
        bizSafeDocAttach.setCatalogDetailId(oldBizSafeDocAttach.getCatalogDetailId());
        return bizSafeDocAttachMapper.updateBizSafeDocAttach(bizSafeDocAttach);
    }

    /**
     * 查询文件列表
     * @param bizSafeInforFileListDTO
     * @return
     */
    @Override
    public List<BizSafeDocAttachVO> selectFileList(BizSafeInforFileListDTO bizSafeInforFileListDTO) {
        BizSafeDocAttach bizSafeDocAttach = new BizSafeDocAttach();
        bizSafeDocAttach.setSearchValue(bizSafeInforFileListDTO.getFileName());
        bizSafeDocAttach.setStartTime(bizSafeInforFileListDTO.getStartTime());
        bizSafeDocAttach.setEndTime(bizSafeInforFileListDTO.getEndTime());
        //查询安全内业资料下所有的需要上传文件的id集合
        BizSafeInfor queryBizSafeInfor = new BizSafeInfor();
        if(bizSafeInforFileListDTO.getSafeInforId() != null){
            BizSafeInfor bizSafeInfor = bizSafeInforMapper.selectBizSafeInforById(bizSafeInforFileListDTO.getSafeInforId());
            queryBizSafeInfor.setAncestors(bizSafeInfor.getPath());
        }else{
            queryBizSafeInfor.setAncestors(CatalogConstants.ROOT_ID_CHAR);
        }
        queryBizSafeInfor.setCreateJunior(CatalogConstants.NO_NEED_CREATE_JUNIOR);
        queryBizSafeInfor.setProjectId(bizSafeInforFileListDTO.getProjectId());
        List<BizSafeInfor> bizSafeInfors = bizSafeInforMapper.selectBizSafeInforList(queryBizSafeInfor);
        List<Long> bizSafeInforIds = bizSafeInfors.stream().map((item)->item.getId()).collect(Collectors.toList());
        if(bizSafeInforFileListDTO.getSafeInforId() != null) {
            bizSafeInforIds.add(bizSafeInforFileListDTO.getSafeInforId());
        }
        if(bizSafeInforIds.size()>0){
            bizSafeDocAttach.setCatalogDetailIds(bizSafeInforIds);
            return bizSafeDocAttachService.selectBizSafeDocAttachList(bizSafeDocAttach);
        }else{
            return new ArrayList<>();
        }
    }

    /**
     * 递归目录插入到安全内业目录中
     * @param bizCatalogDetails
     * @param projectId
     */
    public void copyBizCatalogDetails(List<BizCatalogDetail> bizCatalogDetails,Long projectId){
        if(bizCatalogDetails.size()>0) {
            bizCatalogDetails.forEach((bizCatalogDetail -> {
                BizSafeInfor bizSafeInfor = new BizSafeInfor(bizCatalogDetail);
                if (bizCatalogDetail.getParentId() == 0) {
                    bizSafeInfor.setParentId(0l);
                    bizSafeInfor.setAncestors("0");
                } else {
                    bizSafeInfor.setParentId(bizCatalogDetail.getParentId());
                    BizSafeInfor parentBizSafeInfor = bizSafeInforMapper.selectBizSafeInforById(bizCatalogDetail.getParentId());
                    bizSafeInfor.setAncestors(parentBizSafeInfor.getAncestors() +"," + parentBizSafeInfor.getId());
                }
                bizSafeInfor.setProjectId(projectId);
                bizSafeInfor.setDeptId(SecurityUtils.getDeptId());
                bizSafeInfor.setCreateBy(SecurityUtils.getUsername());
                bizSafeInfor.setCreateTime(DateUtils.getNowDate());
                bizSafeInforMapper.insertBizSafeInfor(bizSafeInfor);
                List<BizCatalogDetail> subBizCatalogDetails = bizCatalogDetailMapper.selectDetailByParentId(bizCatalogDetail.getId());
                subBizCatalogDetails.forEach((subBizCatalogDetail)->{
                    subBizCatalogDetail.setParentId(bizSafeInfor.getId());
                });
                copyBizCatalogDetails(subBizCatalogDetails,projectId);
            }));
        }
    }
}
